package com.yanxu.proxy.proxy_dynamic;

import com.yanxu.proxy.base.IOrderService;
import com.yanxu.proxy.base.Order;
import com.yanxu.proxy.base.OrderServiceImpl;

/**
 * @author 折戟沉沙铁未销
 * @version V1.0
 * @date 2025/4/15-2025
 * @Description: 这里用一句话描述这个类的作用
 */
public class Test1 {
    public static void main(String[] args) {
        Order order = new Order();
        order.setUserId(2);

        //根据 原target 生成动态代理对象
        IOrderService orderService = new OrderServiceImpl();

        OrderServiceDynamicProxy orderServiceDynamicProxy =
                new OrderServiceDynamicProxy(orderService);

        IOrderService enhanceOrderService = (IOrderService) orderServiceDynamicProxy.getProxy();

        //使用代理对象进行数据保存
        int i = enhanceOrderService.saveOrder(order);

    }
}